home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / t2win-32 / _printer.frm (.txt) < prev    next >
Visual Basic Form  |  1998-07-13  |  14KB  |  297 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPrinter 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Printer"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   4845
  13.    ScaleWidth      =   7485
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame1 
  16.       Height          =   570
  17.       Left            =   0
  18.       TabIndex        =   1
  19.       Top             =   -90
  20.       Width           =   7485
  21.       Begin VB.CommandButton cmdNP 
  22.          Caption         =   ">"
  23.          Height          =   285
  24.          Index           =   1
  25.          Left            =   7110
  26.          TabIndex        =   6
  27.          Top             =   195
  28.          Width           =   285
  29.       End
  30.       Begin VB.CommandButton cmdNP 
  31.          Caption         =   "<"
  32.          Height          =   285
  33.          Index           =   0
  34.          Left            =   6210
  35.          TabIndex        =   5
  36.          Top             =   195
  37.          Width           =   285
  38.       End
  39.       Begin VB.CommandButton Command1 
  40.          Caption         =   "&Go"
  41.          Default         =   -1  'True
  42.          Height          =   285
  43.          Left            =   6570
  44.          TabIndex        =   4
  45.          Top             =   195
  46.          Width           =   465
  47.       End
  48.       Begin VB.ComboBox cmb_Function 
  49.          Height          =   315
  50.          Left            =   1365
  51.          TabIndex        =   2
  52.          Top             =   180
  53.          Width           =   4755
  54.       End
  55.       Begin VB.Label Label2 
  56.          Caption         =   "&Select a function"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   3
  60.          Top             =   210
  61.          Width           =   1275
  62.       End
  63.    End
  64.    Begin VB.TextBox txt_Result 
  65.       BackColor       =   &H00C0C0C0&
  66.       BorderStyle     =   0  'None
  67.       Height          =   4110
  68.       Left            =   105
  69.       Locked          =   -1  'True
  70.       MultiLine       =   -1  'True
  71.       ScrollBars      =   2  'Vertical
  72.       TabIndex        =   0
  73.       Top             =   630
  74.       Width           =   7260
  75.    End
  76. Attribute VB_Name = "frmPrinter"
  77. Attribute VB_GlobalNameSpace = False
  78. Attribute VB_Creatable = False
  79. Attribute VB_PredeclaredId = True
  80. Attribute VB_Exposed = False
  81. Option Explicit
  82. Option Base 1
  83. Private Const Iteration = 25
  84. Dim IsLoaded         As Integer
  85. Dim TimerStartOk     As Integer
  86. Dim TimerCloseOk     As Integer
  87. Dim TimerHandle      As Integer
  88. Dim TimerValue       As Long
  89. Private Sub cmb_Function_Click()
  90.    If (IsLoaded = False) Then Exit Sub
  91.    Call cDisableFI(mdiT2W.Picture1)
  92.    txt_Result = ""
  93.    DoEvents
  94.    Select Case cmb_Function.ListIndex
  95.       Case 0
  96.          Call TestEnumPJ
  97.       Case 1
  98.          Call TestPrinterPrintableArea
  99.       Case 2
  100.          Call TestPrinterX
  101.       Case 3
  102.          Call TestEnumPrinters
  103.    End Select
  104.    DoEvents
  105.    Call cEnableFI(mdiT2W.Picture1)
  106. End Sub
  107. Private Sub cmdNP_Click(Index As Integer)
  108.    Call sub_NextPrev(cmb_Function, Index)
  109. End Sub
  110. Private Sub Form_Activate()
  111.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  112. End Sub
  113. Private Sub Form_Load()
  114.    IsLoaded = False
  115.    Show
  116.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_printer.t2w")
  117.    IsLoaded = True
  118. End Sub
  119. Private Sub Command1_Click()
  120.    Call cmb_Function_Click
  121. End Sub
  122. Private Sub TestEnumPJ()
  123.    Dim intResult        As Integer
  124.    Dim strDisplay       As String
  125.    Dim i                As Integer
  126.    strDisplay = ""
  127.    Dim JI               As tagJOBINFO
  128.    intResult = cEnumPrinterJobs("LPT1:", JI, True)
  129.    Do While (intResult = EPJ_SUCCESS)
  130.       strDisplay = strDisplay + "sPrinterName : '" & JI.sPrinterName & "'" & vbCrLf
  131.       strDisplay = strDisplay + "sMachineName : '" & JI.sMachineName & "'" & vbCrLf
  132.       strDisplay = strDisplay + "sUserName : '" & JI.sUserName & "'" & vbCrLf
  133.       strDisplay = strDisplay + "sDocument : '" & JI.sDocument & "'" & vbCrLf
  134.       strDisplay = strDisplay + "lJobId : " & JI.lJobId & vbCrLf
  135.       strDisplay = strDisplay + "lStatus : " & JI.lStatus & vbCrLf
  136.       strDisplay = strDisplay + "lPriority : " & JI.lPriority & vbCrLf
  137.       strDisplay = strDisplay + "lPosition : " & JI.lPosition & vbCrLf
  138.       strDisplay = strDisplay + "lStartTime : " & JI.lStartTime & vbCrLf
  139.       strDisplay = strDisplay + "lUntilTime : " & JI.lUntilTime & vbCrLf
  140.       strDisplay = strDisplay + "lTotalPages : " & JI.lTotalPages & vbCrLf
  141.       strDisplay = strDisplay + "lPagesPrinted : " & JI.lPagesPrinted & vbCrLf
  142.       strDisplay = strDisplay + "lSize : " & JI.lSize & vbCrLf
  143.       strDisplay = strDisplay + "lTime : " & JI.lTime & vbCrLf
  144.       strDisplay = strDisplay + "Submitted : " & JI.wMonth & "/" & JI.wDay & "/" & JI.wYear & " " & JI.wHour & ":" & JI.wMinute & ":" & JI.wSecond & vbCrLf & vbCrLf
  145.       
  146.       intResult = cEnumPrinterJobs("LPT1:", JI, False)
  147.    Loop
  148.    txt_Result = strDisplay
  149.    'time the function
  150.    TimerHandle = cTimerOpen()
  151.    TimerStartOk = cTimerStart(TimerHandle)
  152.    For i = 1 To Iteration
  153.       intResult = cEnumPrinterJobs("LPT1:", JI, True)
  154.    Next i
  155.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  156.    TimerCloseOk = cTimerClose(TimerHandle)
  157. End Sub
  158. Private Sub TestPrinterPrintableArea()
  159.    Dim intResult        As Integer
  160.    Dim strDisplay       As String
  161.    Dim sngResult        As Single
  162.    Dim i                As Integer
  163.    strDisplay = ""
  164.    strDisplay = strDisplay + "Printer width : " & cPrinterWidth(Printer.hDC) & vbCrLf
  165.    strDisplay = strDisplay + "Printer height : " & cPrinterHeight(Printer.hDC) & vbCrLf
  166.    strDisplay = strDisplay + "Printer offset left : " & cPrinterOffsetLeft(Printer.hDC) & vbCrLf
  167.    strDisplay = strDisplay + "Printer offset top : " & cPrinterOffsetTop(Printer.hDC) & vbCrLf
  168.    txt_Result = strDisplay
  169.    'time the function
  170.    TimerHandle = cTimerOpen()
  171.    TimerStartOk = cTimerStart(TimerHandle)
  172.    For i = 1 To Iteration
  173.       sngResult = cPrinterWidth(Printer.hDC)
  174.    Next i
  175.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  176.    TimerCloseOk = cTimerClose(TimerHandle)
  177. End Sub
  178. Private Sub TestPrinterX()
  179.    Dim intResult        As Integer
  180.    Dim strDisplay       As String
  181.    Dim sngResult        As Single
  182.    Dim i                As Integer
  183.    Dim iValue           As Integer
  184.    Dim iCopies          As Integer
  185.    Dim iDefaultSource   As Integer
  186.    Dim iDitherType      As Integer
  187.    Dim iOrientation     As Integer
  188.    Dim iPaper           As Integer
  189.    Dim iQuality         As Integer
  190.    strDisplay = ""
  191.    strDisplay = strDisplay + "GetPrinter informations " & vbCrLf & vbCrLf
  192.    intResult = cGetPrinterCopies("LPT1:", iCopies)
  193.    strDisplay = strDisplay + "   Copies = " & iCopies & vbCrLf
  194.    intResult = cGetPrinterDefaultSource("LPT1:", iDefaultSource)
  195.    strDisplay = strDisplay + "   Default Source = " & iDefaultSource & vbCrLf
  196.    intResult = cGetPrinterDitherType("LPT1:", iDitherType)
  197.    strDisplay = strDisplay + "   Dither Type = " & iDitherType & vbCrLf
  198.    intResult = cGetPrinterOrientation("LPT1:", iOrientation)
  199.    strDisplay = strDisplay + "   Orientation = " & iOrientation & vbCrLf
  200.    intResult = cGetPrinterPaper("LPT1:", iPaper)
  201.    strDisplay = strDisplay + "   Paper = " & iPaper & vbCrLf
  202.    intResult = cGetPrinterQuality("LPT1:", iQuality)
  203.    strDisplay = strDisplay + "   Quality = " & iQuality & vbCrLf & vbCrLf
  204.    strDisplay = strDisplay + "SetPrinter informations " & vbCrLf & vbCrLf
  205.    intResult = cSetPrinterCopies("LPT1:", 7)
  206.    strDisplay = strDisplay + "   Set Copies to 7 = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  207.    intResult = cSetPrinterDefaultSource("LPT1:", SP_SOURCE_LOWER)
  208.    strDisplay = strDisplay + "   Set DefaultSource to SP_SOURCE_LOWER = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  209.    intResult = cSetPrinterDitherType("LPT1:", SP_DITHER_LINEART)
  210.    strDisplay = strDisplay + "   Set DitherType to SP_DITHER_LINEART = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  211.    intResult = cSetPrinterOrientation("LPT1:", SP_ORIENTATION_LANDSCAPE)
  212.    strDisplay = strDisplay + "   Set Orientation to SP_ORIENT